package han.chensing.latos.maker.util;

import com.badlogic.gdx.scenes.scene2d.ui.List;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import han.chensing.latos.maker.function.AsString;

public class UIListUtil {
    public static <T> void updateList(
            List<String> list, ScrollPane scrollPane, java.util.List<T> tList, AsString<T> str){
        if (list==null||scrollPane==null||tList==null)
            return;
        list.clearItems();
        for (T t:tList)
            list.getItems().add(str.apply(t));
        list.invalidateHierarchy();
        scrollPane.invalidateHierarchy();
    }
}
